package com.renting.modules.message.utils;

import cn.jpush.api.push.model.Message;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.audience.AudienceTarget;
import cn.jpush.api.push.model.notification.Notification;
import com.renting.common.config.CommonConstant;
import com.renting.modules.message.entity.SimpleMessage;

public class PayLoadUtils {

    /**
     * 简单的只发送内容
     * @param message
     * @return
     */
    public static PushPayload buildPushObject_all_alert(SimpleMessage message) {
        return PushPayload.alertAll(message.getContent());
    }

    /**
     * 内容 + 标题 + android端限制
     * @param message
     * @return
     * @error
     */
    public static PushPayload buildPushObject_android_alertWithTitle(SimpleMessage message) {
        return PushPayload.newBuilder()
                .setPlatform(Platform.android())
                .setAudience(Audience.all())
                .setNotification(Notification.android(message.getContent(), message.getName(), null))
                .build();
    }

    /**
     * 自定义消息
     */
    public static void pushCustomMessage(SimpleMessage message){

    }

    /**
     * 自定义消息推送给指定tag用户
     * @param message
     * @return
     */
    public static PushPayload buildPushObject_ios_audienceMore_messageWithExtras(SimpleMessage message) {
        return PushPayload.newBuilder()
                .setPlatform(Platform.android_ios())
                .setAudience(Audience.newBuilder()
                        .addAudienceTarget(AudienceTarget.tag(CommonConstant.DEFAULT_TAG))
                        .build())
                .setMessage(Message.newBuilder()
                        .setTitle(message.getName())
                        .setMsgContent(message.getContent())
                        .build())
                .build();
    }

}
